(function ($) {
	$.fn.extend({
		leanModal : function (options) {
			var defaults = {
				top : 100,
				overlay : 0.5,
				closeButton : null
			};
			var overlay = $("<div id='tcc'></div>");
			$("body").append(overlay);
			options = $.extend(defaults, options);
			return this.each(function () {
				var o = options;
				$(this).click(function (e) {
					var modal_id = $(this).attr("href");
					$("#tcc").click(function () {
						close_modal(modal_id)
					});
					$(o.closeButton).click(function () {
						close_modal(modal_id)
					});
					var modal_height = $(modal_id).outerHeight();
					var modal_width = $(modal_id).outerWidth();
					$("#tcc").css({
						"display" : "block",
						opacity : 0
					});
					$("#tcc").fadeTo(200, o.overlay);
					$(modal_id).css({
						"display" : "block",
						"position" : "fixed",
						"opacity" : 0,
						"z-index" : 9997,
						"left" : 50 + "%",
						"margin-left" :  - (modal_width / 2) + "px",
						"top" : o.top + "px"
					});
					$(modal_id).fadeTo(200, 1);
					e.preventDefault()
				})
			});
			function close_modal(modal_id) {
				$("#tcc").fadeOut(200);
				$(modal_id).css({
					"display" : "none"
				})
			}
		}
	})
})(jQuery);

$(function () {
	$(".ds-shang").leanModal({
		top : 120,
		overlay : 0.45
	});
	$(".ds-shares").leanModal({
		top : 145,
		overlay : 0.45
	});
	$(".ds-like").click(function () {
		var $this = $(this);
		$.getJSON(DS_AjaxUrl,
      {value : $this.data("value")},
			function (data, status) {
			if (data.code == "ok") {
				$(".ds-like .num").text(data.value);
			} else {
				alert(data.text);
			}
		});
	});
});
